import { chromium } from 'playwright';

(async () => {
  const executablePath =
      process.env.PUPPETEER_EXECUTABLE_PATH ||
      {
        linux: '/usr/bin/chromium-browser',
        win32: 'C:\\Program Files (x86)\\Google\\Chrome',
        darwin: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
      }[process.platform];
  const browser = await chromium.launch({
    executablePath,
  });
  const page = await browser.newPage(); // 2
  await page.setViewportSize({ width: 1280, height: 800 }); // 3
  await page.goto('https://playwright.dev/', {
    waitUntil: 'networkidle', // 4
  });
  await page.screenshot({ path: 'example.png' });
  await browser.close();
})();